{	Problem: http://codeforces.ru/problemset/problem/65/B
	Verdict: Accepted
}
uses sysutils;
var i,n,p,k,cur,m:longint; j:char; a:array[0..1010] of longint; t:string;
begin
read(n);
for i:=1 to n do read(a[i]);
p:=0;
for i:=1 to n do begin
  m:=maxlongint;
  for k:=1 to 4 do begin
    t:=inttostr(A[i]);
    for j:='0' to '9' do
      if not((k=1) and (j='0')) then begin
        t[k]:=j;
        cur:=strtoint(t);
        if (cur<m) and (cur>=p) then m:=cur;
      end;
  end;
  a[i]:=m;
  p:=a[i];
end;
if a[n]<2012 then
  for i:=1 to n do writeln(a[i])
else write('No solution');
end.
